package com.lavender.util.web;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.util.WebUtils;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * <p>
 *  WebUtils：基于Request得到的信息，比如Cookie，Session等
 * </p>
 *
 * @author: zhu.chen
 * @date: 2021/3/29
 * @version: v1.0.0
 */
@RestController
public class WebUtilsTest {

    @GetMapping("/hello")
    public String hello(HttpServletRequest request) {
        HttpSession httpSession = request.getSession();
        System.out.println(WebUtils.getSessionId(request));
        System.out.println(WebUtils.getCookie(request, "name").getValue());
        return "hello";
    }

}
